package com.trainfinder.proxy;

import java.io.IOException;
import java.net.ServerSocket;

public class ProxyServiceFactory implements ServiceProviderFactory {

	private final ServerSocket socketServer;

	public ProxyServiceFactory() throws ServerCreationException {

		try {
			socketServer = new ServerSocket(123);
		} catch (IOException e) {
			throw new ServerCreationException(e);
		}

	}

	/**
	 * @param args
	 * @throws ServerCreationException
	 * @throws IOException
	 */
	public ServiceProvider newInstance() throws ServerCreationException {

		return new ServiceProviderImpl(socketServer);
	}


	public void close() {
		try {
			socketServer.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			//
		}
	}

}
